Object-oriented programming, also referred to as OOP, is a computer programming paradigm based on the concept of objects. A computer program may be designed from many different objects having different functions. An object may include data in the form of attributes (fields) and code in the form of procedures (methods). Typically, an object's methods can access and modify data fields of other objects with which they are associated. In OOP, computer programs are designed by making them out of objects that interact with one another. There is significant diversity of OOP languages, but the most popular are class-based in that objects are instances of classes, which typically also determine their type. A class can provide a definition for a data format and available procedures for a given type or class of object. In some cases, classes may also contain data and procedures known as class methods. Meanwhile, an object is an instance of a class.
Object copying is a process of creating a copy of an existing object. The resulting copy may be referred to as an object copy. Copying is a basic idea but has subtleties and can have significant overhead. The design goal of most objects is to give the resemblance of being made out of one monolithic block even though the object is not a single block but rather a composite of data from multiple underlying data objects. Because objects are made up of several different parts or layers, copying can be difficult. There are several ways to copy an object, most commonly by a copy constructor or cloning. One method of copying an object is the shallow copy. In this case, a new object is created, and the field values of the original object are copied over to the new object. This is also referred to as a field-by-field copy. Another copy method is a deep copy in which fields are de-referenced rather than references to objects being copied. In this example, new copy objects are created for any de-referenced objects, and references to the new copy objects are placed in the new object. Other copy processes exist including hybrids of the shallow and deep copy procedures. In any case, the copy of an object creates a redundant storage of the underlying data of the object and also require significant processing time and resources to perform the operation. Accordingly, a better method of cloning an object is needed.
Throughout the drawings and the detailed description, unless otherwise described, the same drawing reference numerals will be understood to refer to the same elements, features, and structures. The relative size and depiction of these elements may be exaggerated or adjusted for clarity, illustration, and/or convenience.